package ch4.hw1;

public class JavaArrayHW {
	// array of strings 3names+, print names, print the longest using any type
	// of loop
	public static void main(String[] args) {
		String[] names = { "Jan", "Ulka", "Krzysztof", "Tomasz" };

		Integer idx = 0;
		while (idx < names.length) {
			System.out.println(names[idx]);
			idx++;
		}
		System.out.println("--");

		String thelongest = names[0];
		String compared = names[1];
		Integer idx2 = 0;
		while (idx2 + 1 < names.length) {
			while (compared.length() > thelongest.length()) {
				thelongest = compared;

			}
			idx2++;

			while (idx2 + 1 < names.length) {
				compared = names[idx2 + 1];
				break;

			}

		}

		System.out.println("The longest name is: ");
		System.out.println(thelongest);

	}
}
